a dose of (one's) own medicine

Translations
être pris à son propre jeu
Definitions
An experience in which someone is treated in the same negative or unpleasant way that they have treated others, often as a form of retribution or poetic justice.